package com.view;

import java.io.File;
import java.io.FileNotFoundException;

import android.app.Activity;
import android.content.Intent;
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.net.Uri;
import android.os.Bundle;
import android.os.Environment;
import android.provider.MediaStore;
import android.util.Log;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;

public class TakePhotoActivity extends Activity implements OnClickListener {
	private static int TAKE_PICTURE = 1;
	private Uri outputFileUri;

	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.takephoto);
		Button takePhoto;
		takePhoto = (Button) findViewById(R.id.takephoto_photo);
		takePhoto.setOnClickListener(this);
	}

	public void onClick(View v) {
		// Intent intent = new Intent(TakePhotoActivity.this,
		// SendPhotoActivity.class);
		// startActivity(intent);
		Intent intent = new Intent(MediaStore.ACTION_IMAGE_CAPTURE);
		File file = new File(Environment.getExternalStorageDirectory(), "sample.jpg");
		outputFileUri = Uri.fromFile(file);
		intent.putExtra(MediaStore.EXTRA_OUTPUT, outputFileUri);
		startActivityForResult(intent, TAKE_PICTURE);
	}

	@Override
	protected void onActivityResult(int requestCode, int resultCode, Intent data) {
		// TODO Auto-generated method stub
		Intent intent;
		if (requestCode == TAKE_PICTURE) {
			Log.d("#####BUMP", getIntent().getAction().toString());
			if (getIntent().getAction().toString().equals("BUMP")) {
				intent = new Intent(TakePhotoActivity.this, BumpChat.class);
			} else {
				intent = new Intent(TakePhotoActivity.this, SendPhotoActivity.class);
			}
			// intent.setData(outputFileUri);
			startActivity(intent);
		}
		super.onActivityResult(requestCode, resultCode, data);
	}
}
